﻿using System;
using System.Collections.Generic;

namespace Terraria.ModLoader
{
	// Token: 0x02000176 RID: 374
	internal static class GlobalBgStyleLoader
	{
		// Token: 0x06000F2B RID: 3883 RVA: 0x00401AA4 File Offset: 0x003FFCA4
		internal unsafe static void ResizeAndFillArrays(bool unloading = false)
		{
			ModLoader.BuildGlobalHook<GlobalBgStyle, GlobalBgStyleLoader.DelegateChooseUgBgStyle>(ref GlobalBgStyleLoader.HookChooseUgBgStyle, GlobalBgStyleLoader.globalBgStyles, (GlobalBgStyle g) => (GlobalBgStyleLoader.DelegateChooseUgBgStyle)Delegate.CreateDelegate(typeof(GlobalBgStyleLoader.DelegateChooseUgBgStyle), g, methodof(GlobalBgStyle.ChooseUgBgStyle(int*))));
			ModLoader.BuildGlobalHook<GlobalBgStyle, GlobalBgStyleLoader.DelegateChooseSurfaceBgStyle>(ref GlobalBgStyleLoader.HookChooseSurfaceBgStyle, GlobalBgStyleLoader.globalBgStyles, (GlobalBgStyle g) => (GlobalBgStyleLoader.DelegateChooseSurfaceBgStyle)Delegate.CreateDelegate(typeof(GlobalBgStyleLoader.DelegateChooseSurfaceBgStyle), g, methodof(GlobalBgStyle.ChooseSurfaceBgStyle(int*))));
			ModLoader.BuildGlobalHook<GlobalBgStyle, Action<int, int[]>>(ref GlobalBgStyleLoader.HookFillUgTextureArray, GlobalBgStyleLoader.globalBgStyles, (GlobalBgStyle g) => (Action<int, int[]>)Delegate.CreateDelegate(typeof(Action<int, int[]>), g, methodof(GlobalBgStyle.FillUgTextureArray(int, int[]))));
			ModLoader.BuildGlobalHook<GlobalBgStyle, Action<int, float[], float>>(ref GlobalBgStyleLoader.HookModifyFarSurfaceFades, GlobalBgStyleLoader.globalBgStyles, (GlobalBgStyle g) => (Action<int, float[], float>)Delegate.CreateDelegate(typeof(Action<int, float[], float>), g, methodof(GlobalBgStyle.ModifyFarSurfaceFades(int, float[], float))));
			if (!unloading)
			{
				GlobalBgStyleLoader.loaded = true;
			}
		}

		// Token: 0x06000F2C RID: 3884 RVA: 0x0000E5B0 File Offset: 0x0000C7B0
		internal static void Unload()
		{
			GlobalBgStyleLoader.loaded = false;
			GlobalBgStyleLoader.globalBgStyles.Clear();
		}

		// Token: 0x040012AB RID: 4779
		internal static readonly IList<GlobalBgStyle> globalBgStyles = new List<GlobalBgStyle>();

		// Token: 0x040012AC RID: 4780
		internal static bool loaded = false;

		// Token: 0x040012AD RID: 4781
		internal static GlobalBgStyleLoader.DelegateChooseUgBgStyle[] HookChooseUgBgStyle;

		// Token: 0x040012AE RID: 4782
		internal static GlobalBgStyleLoader.DelegateChooseSurfaceBgStyle[] HookChooseSurfaceBgStyle;

		// Token: 0x040012AF RID: 4783
		internal static Action<int, int[]>[] HookFillUgTextureArray;

		// Token: 0x040012B0 RID: 4784
		internal static Action<int, float[], float>[] HookModifyFarSurfaceFades;

		// Token: 0x02000177 RID: 375
		// (Invoke) Token: 0x06000F2F RID: 3887
		internal delegate void DelegateChooseUgBgStyle(ref int style);

		// Token: 0x02000178 RID: 376
		// (Invoke) Token: 0x06000F33 RID: 3891
		internal delegate void DelegateChooseSurfaceBgStyle(ref int style);
	}
}
